﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Globalization;
using System.Web.Services;
using Public;

namespace WebsiteAdmin.Wilson.AdInfo.Handler
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class Delete : IHttpHandler
    {
        private string respondText = "";
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (Cookie.AdminLoginName != null || Cookie.AdminLoginName != "")  //登陆判断
            {
                int pkid = Convert.ToInt32(context.Request["pkid"]);
                respondText = DELETE_SINGLE(Global.ConnWilson, pkid);
                context.Response.Write(respondText);
            }
            else
            {
                context.Response.Clear();
                context.Response.CacheControl = "no-cache";
                context.Response.Write("");
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        protected static string DELETE_SINGLE(string strCon, int pkid)
        {
            string respondText = "";
            int result = Bll.CategoryAd.DELETE(strCon, pkid);
            if (result == 1)
            {
                respondText = "{\"Done\":\"Success\"}";
            }
            else
            {
                respondText = "{\"Done\":\"Failed\"}";
            }
            return respondText;
        }
    }
}
